package com.likeycy.my;

import com.likeycy.my.printer.BinaryTrees;
import com.likeycy.my.tree.RedBlackTree;

/**
 * @ClassName: TestRedBlackTree
 * @Description: 测试自定义的红黑树
 * @Author: sodagreen
 * @Date: 2021/3/22 23:28
 * @Version: 1.0
 */
public class TestRedBlackTree {

    static int[] intArray = new int[] {
            96, 60, 33, 17, 74, 49, 94, 58
    };

    public static void main(String[] args) {
//        testAfterAdd();
        testAfterRemove();
    }

    /**
     * 添加后
     */
    public static void testAfterAdd() {
        RedBlackTree<Integer> redBlackTree = new RedBlackTree<Integer>();
        for (int i = 0; i < intArray.length; i++) {
            redBlackTree.add(intArray[i]);
            System.out.println(intArray[i]);
            BinaryTrees.println(redBlackTree);
            System.out.println("=======================================================================");
        }
    }

    public static void testAfterRemove() {
        RedBlackTree<Integer> redBlackTree = new RedBlackTree<Integer>();
        for (int i = 0; i < intArray.length; i++) {
            redBlackTree.add(intArray[i]);
        }

        BinaryTrees.println(redBlackTree);
        System.out.println("=======================================================================");

        for (int i = 0; i < intArray.length; i++) {
            redBlackTree.remove(intArray[i]);
            System.out.println(intArray[i]);
            BinaryTrees.println(redBlackTree);
            System.out.println("=======================================================================");
        }
    }

}
